package com.shamar.blog.enums;


/**
 * @author fangxiaoming
 * @version 1.0
 * @date 2020-07-28 17:24
 * @project channel
 * @desrciption 申请退款三方返回错误信息枚举类 由于通联错误代码和错误信息比较乱 暂不包括通联
 */
public enum RefundErrorEnum {
    WECHAT_USER_ACCOUNT_ABNORMAL("2", "USER_ACCOUNT_ABNORMAL", "用户账户异常或已注销，不能原路退回，请使用其他方式进行退款。"),
    WECHAT_REFUND_NOT_EXIST("2", "REFUNDNOTEXIST", "not exist"),
    WECHAT_FREQUENCY_LIMITED("2", "FREQUENCY_LIMITED", "你的操作过于频繁，请稍后再试。"),
    WECHAT_TIME_OUT("2", "TIME_OUT", "请求超时"),
    WECHATH5_USER_ACCOUNT_ABNORMAL("9", "USER_ACCOUNT_ABNORMAL", "用户账户异常或已注销，不能原路退回，请使用其他方式进行退款。"),
    WECHATH5_REFUND_NOT_EXIST("9", "REFUNDNOTEXIST", "not exist"),
    WECHATH5_FREQUENCY_LIMITED("9", "FREQUENCY_LIMITED", "你的操作过于频繁，请稍后再试。"),
    WECHATH5_TIME_OUT("9", "TIME_OUT", "请求超时"),
    WECHATH5_BIZERR_NEED_RETRY("9", "BIZERR_NEED_RETRY", "系统处理暂未完成，状态未知，请稍后重新发起。"),
    ALIPAY_SYSTEM_ERROR("3", "aop.ACQ.SYSTEM_ERROR", "系统异常"),
    ALIPAY_REFUND_NOT_EXIST("3", "E20007", "退款单不存在"),
    ;

    /**
     * 退款渠道(2微信小程序 9微信H5 3支付宝APP 5通联微信app 6通联微信小程序)
     */
    private String refundChannel;
    /**
     * 错误代码
     */
    private String errCode;
    /**
     * 错误描述信息
     */
    private String errMsg;

    RefundErrorEnum(String refundChannel, String errCode, String errMsg) {
        this.refundChannel = refundChannel;
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public String getRefundChannel() {
        return refundChannel;
    }

    public String getErrCode() {
        return errCode;
    }

    public static RefundErrorEnum getRefundErrorEnumByChannelAndErrCode(String refundChannel, String errCode) {
        for (RefundErrorEnum refundErrorEnum : RefundErrorEnum.values()) {
            if (refundErrorEnum.getRefundChannel().equals(refundChannel) && refundErrorEnum.getErrCode().equals(errCode)) {
                return refundErrorEnum;
            }
        }
        return null;
    }
}
